﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;

namespace NLBS.RegularExpressions
{
    public class HtmlTagRegex : Regex
    {
        // Methods
        public HtmlTagRegex()
        {
            base.pattern = "<(?<endTag>/)?(?<tagname>\\w+)((\\s+(?<attNameValue>(?<attName>\\w+)(\\s*=\\s*(?:\"(?<attVal>[^\"]*)\"|'(?<attVal>[^']*)'|(?<attVal>[^'\">\\s]+)))?))+\\s*|\\s*)(?<completeTag>/)?>";
            base.roptions = RegexOptions.Singleline | RegexOptions.IgnoreCase;
            
            base.capnames = new Hashtable();
            base.capnames.Add("attName", 7);
            base.capnames.Add("attVal", 8);
            base.capnames.Add("0", 0);
            base.capnames.Add("1", 1);
            base.capnames.Add("attNameValue", 6);
            base.capnames.Add("2", 2);
            base.capnames.Add("tagname", 5);
            base.capnames.Add("3", 3);
            base.capnames.Add("completeTag", 9);
            base.capnames.Add("endTag", 4);
            base.capslist = new string[] { "0", "1", "2", "3", "endTag", "tagname", "attNameValue", "attName", "attVal", "completeTag" };
            base.capsize = 10;
            base.InitializeReferences();
        }
    }
}
